import { ResPage, Coupon, Activity } from "@/api/interface/index";
import { PORT1 } from "@/api/config/servicePort";
import http from "@/api";
import qs from "qs";

/**
 * @name 优惠券管理模块
 */

// 优惠券列表列表
export const getFoodCouponList = (params?: {}) => {
  return http.post<ResPage<Coupon.ResFoodCouponList>>(PORT1 + `/corecmsfoodcoupon/GetPageList`, qs.stringify(params));
};

// 新增优惠券
export const createFoodCoupon = (params: {}) => {
  return http.post(PORT1 + `/corecmsfoodcoupon/DoCreate`, params);
};

// 获取优惠券详情  传id
export const getEditFoodCoupon = (params: {}) => {
  return http.post(PORT1 + `/corecmsfoodcoupon/GetEdit`, params);
};

// 编辑优惠券
export const editFoodCoupon = (params: {}) => {
  return http.post(PORT1 + `/corecmsfoodcoupon/DoEdit`, params);
};

// 删除优惠券 传id
export const deleteFoodCoupon = (params: {}) => {
  return http.post(PORT1 + `/corecmsfoodcoupon/DoDelete`, params);
};

// 获取特价折扣商品列表
export const getDiscountRulesList = (params?: {}) => {
  return http.post<ResPage<Coupon.ResDiscountRulesList>>(PORT1 + `/CoreCmsDiscountRules/GetPageList`, qs.stringify(params));
};

// export const getDiscountRulesList = (params?: {}) => {
//   return http.post<ResPage<Coupon.ResDiscountRulesList>>(PORT1 + `/CoreCmsReports/GetPageReport`, params);
// };

// 获取特价折扣详情  传id
export const getDiscountRules = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsDiscountRules/GetEdit`, params);
};

// 编辑特价折扣
export const editDiscountRules = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsDiscountRules/DoEdit`, params);
};

// 新增特价折扣
export const createDiscountRules = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsDiscountRules/DoCreate`, params);
};

// 审核特价折扣
export const examineDiscountRules = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsDiscountRules/Approved`, params);
};

// 停用特价折扣
export const stopDiscountRules = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsDiscountRules/StopUse`, params);
};

// 获取优惠券发放列表
export const getFoodCouponUserList = (params: {}) => {
  return http.post<ResPage<Coupon.ResFoodCouponUserList>>(PORT1 + `/CoreCmsFoodCouponUser/GetPageList`, qs.stringify(params));
};

// 新增礼券发放
export const createFoodCouponUser = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsFoodCouponUser/DoCreate`, params);
};

// 批量新增礼券发放
export const createBatchFoodCouponUser = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsFoodCouponUser/DoCreateBatch`, params);
};

// 编辑礼券发放
export const editFoodCouponUser = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsFoodCouponUser/DoEdit`, params);
};

// 停用礼券
export const stopFoodCouponUser = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsFoodCouponUser/DoStop`, params);
};

// 获取新增礼券编码
export const getFoodCouponUserCode = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsFoodCouponUser/GetCreate`, params);
};

// 创建扫码领券活动
export const createCmssalesPromotion = (params: {}) => {
  return http.post(PORT1 + `/corecmssalespromotion/DoCreate`, params);
};

// 获取活动列表
export const getCmssalesPromotionList = (params: {}) => {
  return http.post<ResPage<Activity.ResActivityCouponList>>(PORT1 + `/corecmssalespromotion/getpagelist`, qs.stringify(params));
};

// 获取活动列表详情
export const getCorecmssalespromotionDetail = (params: {}) => {
  return http.post(PORT1 + `/corecmssalespromotion/GetEdit`, params);
};

// 编辑活动
export const editCorecmssalespromotion = (params: {}) => {
  return http.post(PORT1 + `/corecmssalespromotion/DoEdit`, params);
};
